<%@ page import="java.sql.ResultSet" %>
<%--
  Created by IntelliJ IDEA.
  User: kaibb
  Date: 14-7-26
  Time: 下午1:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="db" class="com.bing.beans.DBJndi" scope="session"/>
<html>
<head>
    <title>Hello Jdbc</title>
</head>
<body>
你好! jdbc.....查询Employee......333

<form action="index.jsp">
    以员工名过滤: <input type="text" name="name">
    <input type="submit" value="过滤">
</form>
<table border="1" width="100%">
    <tr>
        <td> EmployeeId</td>
        <td> FirstName</td>
        <td> LastName</td>
        <td> Email</td>
        <td> PhoneNumber</td>
    </tr>
    <%
        String name = request.getParameter("name") == null ? "" : request.getParameter("name");
        ResultSet resultSet = db.getAllEmployeeByName(name);
        while (resultSet.next()) {
            long id = resultSet.getLong(1);
            String firstName = resultSet.getString(2);
            String lastName = resultSet.getString(3);
            String email = resultSet.getString(4);
            String phoneNumber = resultSet.getString("phone_number");
    %>
    <tr>
        <td><%=id%>
        </td>
        <td><%=firstName%>
        </td>
        <td><%=lastName%>
        </td>
        <td><%=email%>
        </td>
        <td><%=phoneNumber%>
        </td>
    </tr>
    <%
        }
    %>
</table>
</body>
</html>
